Skip to content

Redact sensitive duplicate query parameter values in ApiServlet logs#13677

Open
dheeraj12347 wants to merge 1 commit into
apache:4.20from
dheeraj12347:fix-redact-sensitive-duplicate-params-4.20
Open

Redact sensitive duplicate query parameter values in ApiServlet logs#13677
dheeraj12347 wants to merge 1 commit into
apache:4.20from
dheeraj12347:fix-redact-sensitive-duplicate-params-4.20

Conversation

@dheeraj12347

@dheeraj12347 dheeraj12347 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Description

This PR manually backports the fix from #13559 to the 4.20 LTS branch.

Changes

  • Redact duplicate values for sensitive query parameters before logging in ApiServlet.
  • Add helper methods to identify sensitive parameters and format logged values.
  • Backport the corresponding unit tests.

This backport includes the changes applicable to the 4.20 branch.

Fixes #13311

@dheeraj12347

Copy link
Copy Markdown
Contributor Author

@DaanHoogland

As discussed in #13559, this is the manual backport of the fix for the 4.20 LTS branch.

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some linting but clgtm still

Comment on lines +82 to +94
private static final String REDACTED = "REDACTED";
private static final String LOGGER_REPLACEMENTS = "[\n\r\t]";

private static final Set<String> SENSITIVE_PARAMETER_KEYWORDS = Set.of(
"password",
"privatekey",
"accesskey",
"secretkey",
"apikey",
"signature",
"sessionkey",
"token"
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent seems off

Comment on lines +191 to +201
}

static String formatValuesForLog(String parameterName, String[] values) {
if (!isSensitiveParameter(parameterName)) {
return Arrays.toString(values);
}

String[] masked = new String[values.length];
Arrays.fill(masked, REDACTED);
return Arrays.toString(masked);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent is off for this bit as well

@DaanHoogland

Copy link
Copy Markdown
Contributor

@dheeraj12347 , you should not have to open a new PR (next time) just rebase your fix with git rebase --onto <new branch> <old base>

I think we can close the one on main now and it looks like it won’t give major conflicts when merging forwards.

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.26%. Comparing base (e8df87e) to head (cb3c236).
⚠️ Report is 1 commits behind head on 4.20.

Files with missing lines Patch % Lines
server/src/main/java/com/cloud/api/ApiServlet.java 81.25% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #13677   +/-   ##
=========================================
  Coverage     16.26%   16.26%           
- Complexity    13435    13438    +3     
=========================================
  Files          5667     5667           
  Lines        500731   500746   +15     
  Branches      60803    60803           
=========================================
+ Hits          81430    81466   +36     
+ Misses       410197   410171   -26     
- Partials       9104     9109    +5     
Flag Coverage Δ
uitests 4.14% <ø> (ø)
unittests 17.12% <81.25%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants